<script setup>
const props = defineProps({
  title: String,
  number: {
    type: [Number, String],
    default: 0,
  },
  type: {
    type: String,
    default: '',
  },
  value: [Number, String],
})
</script>
<template>
  <div class="data-item">
    <div class="data-item-title">
      {{ title }}
    </div>
    <div class="data-item-content">
      <ActiveNumber :value="number" />
      <div class="data-item-value" v-if="type === 'down'">
        <span class="down">-{{ value }}</span>
        <img src="@/assets/images/data-item/down.png" alt="" />
      </div>
      <div class="data-item-value" v-if="type === 'up'">
        <span class="up">{{ value }}</span>
        <img src="@/assets/images/data-item/up.png" alt="" />
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.data-item {
  width: 200px;
  height: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  justify-content: center;
  background-image: url('@/assets/images/data-item/border.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  .data-item-title {
    font-family: PingFang SC;
    font-weight: 500;
    font-size: 16px;
    color: #fff;
  }
  .data-item-content {
    font-size: 24px;
    color: #ffbb15;
    font-family: D-DIN-PRO;
    font-weight: 700;
    font-size: 24px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    .data-item-value {
      display: flex;
      align-items: center;
      justify-content: flex-start;
      gap: 4px;
      animation: hide 3s linear infinite;
      img {
        width: 18px;
        height: 18px;
      }
      .down,
      .up {
        display: flex;
        font-weight: 500;
        font-size: 14px;
      }
      .down {
        color: #14de28;
      }
      .up {
        color: #fb0004;
      }
    }
  }
  @keyframes hide {
    0% {
      opacity: 1;
    }
    50% {
      opacity: 0;
    }
    100% {
      opacity: 1;
    }
  }
}
</style>
